Unit WinRes Version 1.20 ßßßßßßßßßßß The WinRes unit is used to utilize Windows' resources and other files. It defines data structures and implements powerful routines for easy access. WinRes Unit: Functions and Procedures WinRes Unit: Type Definitions Supported Resource Types Copyright WinRes Unit: Functions and Procedures ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß AnsiTo437 AnsiTo437Str ConvertMarkers * CreateLinks * DeleteBitmap DoneClasses * FreeStringBlock GetStringFromBlock InitClasses * InsertLink * LoadBitmap LoadBitmapFile LoadCursor LoadDialog * LoadMenu * LoadString LoadStringBlock ReadFontInfo RegisterClass * SkipStub SkipToResource SkipToResourceS SkipToResTbl * These routines are not implemented for Turbo Pascal 6.0. See also: Unit WinRes AnsiTo437 (Unit WinRes) ßßßßßßßßß procedure AnsiTo437(Buf: PChar); This procedure translates a null-terminated string from ANSI character set (code page 1007) to DOS character set (code page 437). AnsiTo437Str (Unit WinRes) ßßßßßßßßßßßß procedure AnsiTo437Str(Str: PString); This procedure translates a Pascal string from ANSI character set (code page 1007) to DOS character set (code page 437). ConvertMarkers (Unit WinRes) ßßßßßßßßßßßßßß function ConvertMarkers(Buf: PChar; Max: Word): Boolean; This function translates a null-terminated string which may include marker characters in Windows' style (&) into a string usable by Turbo Vision or Graphics Vision by inserting marker characters in Vision's style (~~). The string length may grow during this operation. Specify the string buffer size in the Max parameter. ConvertMarkers returns true if the string includes marker characters. CreateLinks (Unit WinRes) ßßßßßßßßßßß procedure CreateLinks(Info: PDialogInfo; Link: pointer); This procedure solves the linking demands of the dialog described by the TDialogInfo structure by creating links to the specified element (Link). Refer to Using Dialog Templates for more information. DeleteBitmap (Unit WinRes) ßßßßßßßßßßßß procedure DeleteBitmap(Bitmap: PBitmap); This procedure deletes a TBitmap structure from the memory. DoneClasses (Unit WinRes) ßßßßßßßßßßß procedure DoneClasses; This procedure closes the dialog and control class management. Refer to Using Dialog Templates for more information. FreeStringBlock (Unit WinRes) ßßßßßßßßßßßßßßß procedure FreeStringBlock(Block: PStringBlock); This procedure deletes a string block from the memory. Refer to: LoadStringBlock GetStringFromBlock GetStringFromBlock (Unit WinRes) ßßßßßßßßßßßßßßßßßß function GetStringFromBlock(Block: PStringBlock; Index: Word): PString; This function searches the specified string block and any linked blocks for the string with the specified index. The function returns a pointer to that string, or NIL if the block including this string is not present. Refer to: LoadStringBlock InitClasses (Unit WinRes) ßßßßßßßßßßß procedure InitClasses; This procedures initializes dialog and control class management. Refer to Using Dialog Templates for more information. InsertLink (Unit WinRes) ßßßßßßßßßß procedure InsertLink(Info: PDialogInfo; AProc: pointer; AControl: pointer); This procedure stores a link to the dialog information structure, that means a label's link to a control element to be defined later. Parameter Description ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Info Pointer to a TDialogInfo structure describing the dialog window to be established. AProc Pointer to TLinkProc procedure which will establish a stored link. AControl Pointer to the label. Refer to Using Dialog Templates for more information. LoadBitmap (Unit WinRes) ßßßßßßßßßß function LoadBitmap(var S: TStream; BitmapName: PChar): PBitmap; This function assumes that the file pointer of the stream points to the resource table. LoadBitmap opens the bitmap resource named BitmapName, and creates a TBitmap structure. Note: Packed bitmaps cannot be loaded in this version. Refer to: DeleteBitmap LoadBitmapFile (Unit WinRes) ßßßßßßßßßßßßßß function LoadBitmapFile( var S: TStream): PBitmap; This function assumes that the file pointer of the stream points to the beginning of a device-independent bitmap file (*.DIB, *.BMP). LoadBitmapFile loads the bitmap from this file and creates a TBitmap structure. Note: Packed bitmaps cannot be loaded in this version. Refer to: DeleteBitmap LoadCursor (Unit WinRes) ßßßßßßßßßß function LoadCursor(var S: TStream; CursorName: PChar): PMyCursor; This function assumes that the file pointer of the stream points to the resource table. LoadCursor opens the mouse cursor resource named CursorName, and creates a TMyCursor data structure. This data structure can be used directly by the MyMouse unit. Define a GetMCursor service routine, which sets the cursor pointer to the data structure if this cursor shape is required. Refer to MyMouse's documentation for details. LoadDialog (Unit WinRes) ßßßßßßßßßß function LoadDialog(var S: TStream; DialogName: PChar): pointer; This function assumes that the file pointer of the stream points to the resource table. LoadDialog opens the dialog template resource named DialogName, and creates a dialog. Refer to Using Dialog Templates for more information. LoadMenu (Unit WinRes) ßßßßßßßß function LoadMenu(var S: TStream; MenuName: PChar; Options: Word): pointer; This function assumes that the file pointer of the stream points to the resource table. LoadMenu opens the menu resource named MenuName, and creates a menu data structure. Using the Options parameter, you can specify the type of menu you need. Options Description ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ mo_TurboVision Creates a structure compatible with TMenu for Turbo Vision. mo_GraphicsVision Creates a structure compatible with TMenu for Graphics Vision, using its extended capabilities. LoadString (Unit WinRes) ßßßßßßßßßß function LoadString(var S: TStream; Index: Word): string; This function assumes that the file pointer of the stream points to the resource table. LoadString retrieves the string with the number Index from the resource. If you need to load more than one string from a resource, you should use LoadStringBlock. LoadStringBlock (Unit WinRes) ßßßßßßßßßßßßßßß function LoadStringBlock(var S: TStream; Index: Word): PStringBlock; This function assumes that the file pointer of the stream points to the resource table. LoadStringBlock loads the string block, consisting of 16 strings, which includes the required string from the resource. Using GetStringFromBlock, you can efficiently access the loaded strings. RegisterClass (Unit WinRes) ßßßßßßßßßßßßß procedure RegisterClass (var ClassRec: TClassRec); This procedure registers a dialog or control class for use with LoadDialog. Before using RegisterClass, InitClasses must be called. A class is described by a static TClassRec structure. Refer to Using Dialog Templates for more information. ReadFontInfo (Unit WinRes) ßßßßßßßßßßßß procedure ReadFontInfo(var S: TStream; var FontInfo: TFontInfo; FontDir: Boolean); This function assumes that the file pointer of the stream points to a font resource, or to an entry of a font directory. ReadFontInfo reads a font description from the stream. After this operation, the file pointer points to the next font description, or the font data. Set FontDir = true, if you are reading from a font directory entry. Use the MyFonts unit for using Windows' fonts, and not this utility routine. SkipStub (Unit WinRes) ßßßßßßßß function SkipStub(var S: TStream): Boolean; This function assumes that S is a stream opened for reading of a new-style EXE file, whose file pointer is at the beginning. The stub (i.e. the old- style EXE portion) is skipped, so that the file pointer is then on the new-style header. The function returns true if it was successful. SkipToResource (Unit WinRes) ßßßßßßßßßßßßßß function SkipToResource(var S: TStream; Name, ResType: PChar): Boolean; This function assumes that S is a stream opened for reading, whose file pointer is at the beginning of the resource table (use SkipStub and SkipToResTbl). The stream is driven to the resource of the given type and name. Use MakeIntResource for converting resource or type numbers into the requested parameters. As the ResType parameter, you can set one of the rt_XXXX constants. Specify NIL as the name if the first resource of the given type is to be used. The function returns true if it was successful. SkipToResourceS (Unit WinRes) ßßßßßßßßßßßßßßß function SkipToResourceS(var S: TStream; Name, ResType: PChar): LongInt; This function performs the same operation as SkipToResource, but returns the size of the resource in bytes. If the resource does not exist, 0 is returned. SkipToResTbl (Unit WinRes) ßßßßßßßßßßßß function SkipToResTbl(var S: TStream): Boolean; This function assumes that S is a stream opened for reading of a new-style EXE file, whose file pointer is at the new-style header (use SkipStub). The stream is driven to the resource table. The function returns true if it was successful. Unit WinRes: Type Definitions ßßßßßßßßßßßßßßßßßßßßßßßßßßßßß Type Description ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ MakeIntClass Translate integer values into class identifiers MakeIntResource Translate integer values into type or resource ids TBgiFontInfo Font information of CHR files TBitmap Logical bitmap TBitmapCoreHeader Header of old-style Windows bitmaps TBitmapCoreInfo Information on old-style Windows bitmaps TBitmapFileHeader Header of Windows bitmap files TBitmapInfo Information on Windows bitmaps TBitmapInfoHeader Header of Windows bitmaps TClassRec Registration record for dialog and control classes TCpiDevCpHeader Data structure in CPI files TCpiFileHeader Header of CPI files TCpiFontHeader Data structure in CPI files TControlData Information on a control element TCursorDirEntry Cursor directory entry TCursorRes Data structure in cursor resources TDialogBoxHeader Information on a dialog template TDialogInfo Information on a dialog window TExeHeader Header of old-style EXE files TFixedVectorInfo Data structure in font resource TFontDir Font directory TFontInfo Data structure in font resource TInitProc Procedure for creating physical dialog windows or control elements TLinkProc Procedure for establishing links TLinkRec Link storage TMenuHeader Data structure in menu resource TMyCursor Mouse cursor in MyMouse's format TNameInfo Resource information TNormalMenuItem Data structure in menu resource TPopUpMenuItem Data structure in menu resource TPropVectorInfo Data structure in font resource TNewRasterInfo Data structure in font resource TRasterInfo Data structure in font resource TResTable Resource table TRGBQuad Color data structure TRGBTriple Color data structure TStringBlock String block TTypeInfo Resource type information TWinHeader Header of new-style EXE files Many types are re-definitions of Windows' structures. Detailed information is available in your Windows API documentation. Refer to: Unit WinRes MakeIntClass (Unit WinRes) ßßßßßßßßßßßß MakeIntClass = PChar Use MakeIntClass to translate an integer value into a class identifier. MakeIntResource (Unit WinRes) ßßßßßßßßßßßßßßß MakeIntResource = PChar Use MakeIntResource to translate an integer value into a class identifier. TClassRec (Unit WinRes) ßßßßßßßßß PClassRec = ^TClassRec; TClassRec = record Class: PChar; Init: pointer; { TInitProc } end; TClassRec is used for providing information on a dialog or control element class. TClassRec records are declared as static, and registered using RegisterClass for use by LoadDialog. Refer to Using Dialog Templates for more information. Entry Description ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Class Null-terminated class identifier. Use MakeIntClass for using integer classes. NIL identifys a generic dialog. Init Initialization/creation procedure for this class. TDialogInfo (Unit WinRes) ßßßßßßßßßßß PDialogInfo = ^TDialogInfo; TDialogInfo = record Base: record x, y: Real end; Move: TPoint; Grow: TPoint; Font: Word; Links: PLinkRec; Group: Boolean; Dialog: pointer; end; TDialogInfo structures are used to store information on a dialog window while it is being created by LoadDialog. Entry Description ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Base Dialog base units Move Start of the client area Grow Size of the client area Font Handle to the font Links List of links to be created Group Indicates the beginning of a control element group Dialog Pointer to the dialog structure Note: The interpretation of most of these entries is implementation- dependent. Refer to Using Dialog Templates for more information. TInitProc (Unit WinRes) ßßßßßßßßß TInitProc = procedure(Data: pointer; Info: PDialogInfo); Use procedures like TInitProc for creating dialog windows or a control element of a certain class. Creating Dialog Windows Data is a pointer to a TDialogBoxHeader data structure. The user-defined procedure must use this information in order to fill out the TDialogInfo structure referenced by Info. A pointer to the dialog created must be put to the Dialog entry of this structure. Creating Control Elements Data is a pointer to a TControlData data structure. The user-defined procedure must use this information in order to create a control element and to insert it into the dialog described by the TDialogInfo structure. Refer to Using Dialog Templates for more information. TLinkProc (Unit WinRes) ßßßßßßßßß TLinkProc = procedure(link, control: pointer); Use procedures like TLinkProc for creating a link between to control elements. Parameter Description ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ link The linked element control The linking element (label) Refer to Using Dialog Templates for more information. TLinkRec (Unit WinRes) ßßßßßßßß PLinkRec = ^TLinkRec; TLinkRec = record Next: PLinkRec; proc: pointer; { TLinkProc } control: pointer end; A list of TLinkRec structures stores link requests. Entry Description ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ Next Pointer to the next structure proc Procedure for creating a link control The linking element (label) Refer to Using Dialog Templates for more information. TMyCursor (Unit WinRes) ßßßßßßßßß PMyCursor = ^TMyCursor; TMyCursor = record mcHeight: Word; mcWidth: Word; mcHotSpotX: Word; mcHotSpotY: Word; mcAND: array[0..127] of Byte; mcXOR: array[0..127] of Byte end; TMyCursor structures are used by the MyMouse unit for representing a mouse cursor. Entry Description ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ mcHeight Pixel height of the cursor mcWidth Byte width of the cursor mcHotSpotX Hot spot x mcHotSpotY Hot spot y mcAND ANDn mask of the cursor mcXOR XOR mask of the cursor Refer to your MyMouse documentation for more information. TStringBlock (Unit WinRes) ßßßßßßßßßßßß PStringBlock = ^TStringBlock; TStringBlock = record sbIndex: Word; sbSize: Word; sbNext: PStringBlock; sbData: record end End; TStringBlock structures are used for representing string blocks loaded from resources in the memory. Entyr Description ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ sbIndex Starting index divided by 16 sbSize String data size sbNext Pointer to the next structure sbData String data Resource Type Constants (Unit WinRes) ßßßßßßßßßßßßßßßßßßßßßßß Constant Resource Type Load Using ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ rt_Cursor Mouse cursor LoadCursor rt_Bitmap Bitmap LoadBitmap rt_Icon Symbol rt_Menu Menu LoadMenu rt_Dialog Dialog template LoadDialog rt_String String table LoadString rt_FontDir Font directory ** rt_Font Font ** rt_Accelerator Key combination rt_RCData Unstructured Data ** You can load fonts (bitmapped and scalable ones) using the MyFonts unit. Unit WinRes: Using Dialog Templates ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß The WinRes Unit provides flexible mechanisms for using Windows' resources describing dialog windows. Using InitClasses, the class management is initialized. Using RegisterClass, you can register the window classes (for dialogs and controls) appearing in the resource. That means, you can define special creation functions for each window class. Using DoneClasses, the class management is closed. Refer to: Unit WinRes Copyright and Disclaimer of Warranty ßßßßßßßßßßßßßßßßßßßßßß The files of the software product provided as a whole are called Software. Copyright The Software is neither "Public Domain", nor "Freeware". The Software is protected by the laws of the Federal Republic of Germany and international treaties. Copyright (C) 1993, 1994 Matthias K”ppe, Erzbergerstraáe 12, D-39104 Magdeburg. All rights reserved. Disclaimer of Warranty The Software is supplied as is. The authors disclaim all warranties, expressed or implied, including but not limited to the warranties of merchantability and of fitness for any purpose. The authors assume no liability for damages, direct or consequential, which may result from the use of the Software. General Agreement Using the Software, you agree to the general agreement, which is stated in the file SOFTWARE.DOC. If you have a copy of the Software that doesn't include this file, refer to: Matthias Koeppe MKM GbR f. Softwareentwicklung Erzbergerstraáe 12 D-39104 Magdeburg GERMANY Phone/Fax +49-391-5 43 01 28 CIS [100331,174]